package hot100;

import java.util.Hashtable;
import java.util.UUID;

/**
 * @author aodre , QQ : 480029069
 * @date 2023/9/13 16:47
 */
public class lc19删除倒数第n节点 {


    /*
     主要 是快指针 先走 n 步, 然后再一起一步一步走! 这个过程要明白!
     */

    public ListNode solve(ListNode head,int n){
        ListNode sentinel = new ListNode(-1),p0 = sentinel, fast = head,slow = sentinel;
        sentinel.next = head;

        // 先 走 n 步
        for (int i = 0; i < n; i++) {
            fast = fast.next;
        }
        while(fast != null){
            fast = fast.next;
            slow = slow.next;
        }
        // slow 刚好在 倒数 第n 节点的pre 位置
        slow.next = slow.next.next;
        return sentinel.next;
    }


    class ListNode {

        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
            next = null;
        }
    }


    public static void main(String[] args) {

        UUID  uuid = UUID.randomUUID();
        System.out.println(uuid);
        UUID  uuid1 = UUID.randomUUID();
        System.out.println(uuid1);

        try{
            System.out.println("hello");

        }catch (RuntimeException e){

        }
        catch (Exception e){

        }

        finally {
//            throw new RuntimeException("this is error");
        }

    }
}
